package vivek.project.pocketmoney.common.renderer
{
	import mx.controls.listClasses.BaseListData;
	import mx.controls.listClasses.IDropInListItemRenderer;
	import mx.controls.listClasses.IListItemRenderer;
	import mx.core.UIComponent;
	import mx.core.UITextField;
	import mx.formatters.NumberFormatter;

	public class AmountRendererAS extends UIComponent implements IListItemRenderer, IDropInListItemRenderer
	{
		// IListItemRenderer implementation
		private var _data:Object;
		//IDropInListItemRenderer implementation:
		private var _listData:BaseListData;
		private var formatter:NumberFormatter=new NumberFormatter();
		private var txt:UITextField;

		public function get data():Object
		{
			return _data;
		}

		public function set data(d:Object):void
		{
			_data=d;
			invalidateProperties();
		}

		// Make the listData property bindable.
		[Bindable("dataChange")]
		public function get listData():BaseListData
		{
			return _listData;
		}

		public function set listData(value:BaseListData):void
		{
			_listData=value;
		}

		//create your children here
		override protected function createChildren():void
		{
			super.createChildren();
			txt=new UITextField();
			txt.percentWidth=100;
			addChild(txt);
		}

		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
		{
			//\\super.updateDisplayList(unscaledWidth, unscaledHeight);
			formatter.precision=2;
			txt.borderColor=000000;
			txt.setStyle("textAlign", "right");
			txt.setActualSize(unscaledWidth, unscaledHeight);
			txt.move(0, 0);
			txt.text=formatter.format(this._listData.label);
		}
	}
}